/*
 * @Description: 缺陷分类接口
 * @Author: Liu Zhiwang
 * @Date: 2021-04-13 20:19:54
 * @LastEditTime: 2021-09-28 14:02:05
 * @LastEditors: Huang Junjie
 */
import request from '@/utils/request'

// 查询列表信息
export function getListPage(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/jcwRepair' + query.unitCodeParams + '/defectCategory/') : '/jcwRepair/defectCategory/',
    url: '/jcwRepair/defectCategory',
    method: 'GET',
    params: params
  })
}

// 根据id查询信息
export function getInfoById(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/jcwRepair' + query.unitCodeParams + `/defectCategory/getById`) : `/jcwRepair/defectCategory/getById`,
    url: `/jcwRepair/defectCategory/getById`,
    method: 'GET',
    params: params
  })
}

// 新增/修改信息
export function addOrEditData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/jcwRepair' + query.unitCodeParams + '/defectCategory/') : '/jcwRepair/defectCategory/',
    url: '/jcwRepair/defectCategory',
    method: 'POST',
    data: params
  })
}

// 删除信息
export function deleteData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/jcwRepair' + query.unitCodeParams + `/defectCategory/${params.id}`) : `/jcwRepair/defectCategory/${params.id}`,
    url: `/jcwRepair/defectCategory/${params.id}`,
    method: 'DELETE'
  })
}

// 获取所有缺陷等级下拉列表
export function getLevelList(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/jcwRepair' + query.unitCodeParams + '/defectCategory/getJcwProblemDefectLevelList') : '/defectCategory/getJcwProblemDefectLevelList',
    url: '/defectCategory/getJcwProblemDefectLevelList',
    method: 'GET',
    params: params
  })
}

// 上下改变排序
export function changeSort(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    // url: query.unitCodeParams ? ('/jcwRepair' + query.unitCodeParams + '/defectCategory/move') : '/jcwRepair/defectCategory/move',
    url: '/jcwRepair/defectCategory/move',
    method: 'POST',
    data: params
  })
}
